/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2025 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
#include "tasks.h"
#include "stm32f1xx_hal_uart.h"


void Task_vidDefaultTask(void)
{
  
  /* Infinite loop */
  //printf("DefaultTask: Running...!\r\n");
  for(;;)
  {
    //HAL_UART_Transmit(&huart3, testMsg, sizeof(testMsg)-1, HAL_MAX_DELAY);
    HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET);  // 设置PB5为高电平
    osDelay(500);  
    //HAL_Delay(500);                                    // 延时1000ms
    HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_RESET);// 设置PB5为低电平
    osDelay(500);                                      // 延时1000ms
    //printf("DefaultTask: Running...!\r\n");
    //HAL_Delay(500);
  }
  /* USER CODE END 5 */
}
extern uint8_t uart3_rx_buffer[128];
extern volatile uint8_t uart3_rx_flag;

void Task_vidStartTask02(void)
{
  /* USER CODE BEGIN StartTask02 */
  //printf("Task02 runnig...!\r\n");
  /* Infinite loop */
  for(;;)
  {
    printf("uart3_rx_buffer: %s\r\n", uart3_rx_buffer);
    if(uart3_rx_flag) {
      printf("UART3 Received: %s\r\n", uart3_rx_buffer);
      uart3_rx_flag = 0;  // 清除标志
      memset((void*)uart3_rx_buffer, 0, sizeof(uart3_rx_buffer)); // 清空缓冲区
    }
    //printf("UART3 Receive : %s \r\n", uart3_rx_buffer);
    //printf("Task02 runnig...!\r\n");
    osDelay(2000);
  }
  /* USER CODE END StartTask02 */
}


